import React, {Component} from 'react'
import {Provider} from 'react-redux'
import store from './Store'
import {BrowserRouter as Router, Route, Link} from 'react-router-dom'
import routes from './Router'

import LKHeader from './Components/Header/LKHeader.jsx'
import LKAside from './Components/Aside/LKAside.jsx'
import Home from './Pages/Home/Home.jsx'

class App extends Component {
    
    render() { 
        return(
            <Provider store = {store}>
                <Router>
                {/* 这样一来可以让包裹的所有App组件都可以获取到store */}
                    <div>
                        <LKHeader/>
                        <div className="main">
                            <LKAside/> 
                            {/* <Route path='/' component={Home}/>  */}
                            {
                                routes.map((route,key)=>{
                                     if(route.exact){
                                         return(
                                            <Route
                                            key={key}
                                            exact 
                                            path={route.path}
                                            render={props=>(
                                                <route.component {...props}/>
                                            )}
                                            />
                                         )
                                    }else{
                                        return (
                                            <Route
                                            key={key} 
                                            path={route.path}
                                            render={props=>(
                                                <route.component {...props}/>
                                            )}
                                            />
                                        )
                                    }
                                })
                            }  
                        </div>
                        
                    </div>
                </Router>
            </Provider>
        ) 
    }
}
 
export default App;